// Dustin Escoffery
// Copyright 2010
#include "inject.h"
#include <windows.h>

static char* PROCESS = "StarCraft.exe";
static char* MODULES[] = { "Window.dll" };
const int NUM_MODULES = 1;

// Executes cmd in suspended mode
int CreateSuspendedProcess(const char* cmd, PPROCESS_INFORMATION lpi)
{
   STARTUPINFO si;
   ZeroMemory(&si, sizeof(si));
   si.cb = sizeof(si);
   ZeroMemory(lpi, sizeof(*lpi));
   return CreateProcess(NULL, (LPTSTR)cmd, NULL, NULL, 0,
      CREATE_SUSPENDED, NULL, NULL, &si, lpi);
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   // Create the suspended process
   PROCESS_INFORMATION pi;
   CreateSuspendedProcess(PROCESS, &pi);

   // Inject the code to load the DLL
   InjectLibs(pi, NUM_MODULES, MODULES);

   // Resume the suspended process
   ResumeThread(pi.hThread);
   return 0;
}
